<?php
/**
 * Created by PhpStorm.
 * User: ycq
 * Date: 18-12-9
 * Time: 下午11:24
 */
require_once 'config.php';
$db = mysqli_connect($db_addr, $db_user, $db_pass, $db_name, $db_prot);
!mysqli_connect_error() or die("连接失败！！");
$username=$_GET['username'];
$name=$_GET['name'];
if($username==''||$name==''){
    echo '内容不允许为空';
    exit();
}
$username=addslashes($username);
$name=addslashes($name);
$sql = "select * from data WHERE username='{$username}'";
$result = $db->query($sql);
if($result->num_rows){
    echo "已存在";
}else{
    $ins="insert into data (name,username,slove) VALUES('$name','$username',0)";
    $db->query($ins);
    echo $db->error;
  	echo '添加成功，如果输入有误请联系管理员';
}